package flightSerialization;

import java.io.*;

public class flightSerialization {

	public static void serialize(String fileName,Object objFlight) throws IOException {
		try
		{
	      OutputStream outputFile = new FileOutputStream( fileName );
	      ObjectOutputStream out = new ObjectOutputStream( outputFile );
	      
	      // writeObject serializes the object
	      out.writeObject(objFlight);
	      
	      out.close();
		}
		catch(Exception ex)
		{
			System.out.println(ex);
		}
	   }   
	   
	   public static Object deserialize(String fileName) throws OptionalDataException, 
	   											ClassNotFoundException, IOException
	   {
	      InputStream inputFile = new FileInputStream( fileName );
	      
	      ObjectInputStream in = new ObjectInputStream( inputFile );
	      
	      // readObject de-serializes the object
	      
	      Object objFlight = in.readObject();
	      
	      return objFlight;
	   }
}
